package breakthrough;

public class Player
{
	public static final int WHITE_PLAYER = 1;
	public static final int BLUE_PLAYER = 2;
	public static final int WHITE_HOME_LEVEL_ROW = 1;
	public static final int BLUE_HOME_LEVEL_ROW = 6;
	private int playerValue;
	
	public Player(int pValue)
	{
		if (pValue == WHITE_PLAYER)
			this.playerValue = WHITE_PLAYER;
		if (pValue == BLUE_PLAYER)
			this.playerValue = BLUE_PLAYER;
	}
	
	/**
	 * Return the player type from a given pawn.
	 * w = white player | b = blue player
	 * @param pawnChar
	 * @return
	 */
	public static int getColorFromPawn(char pawnChar)
	{
		if (pawnChar == 'w')
			return WHITE_PLAYER;
		else
			return BLUE_PLAYER;
	}
	
	public int getPlayerValue()
	{
		return this.playerValue;
	}
	
	public boolean equals(Player p)
	{
		return this.playerValue == p.getPlayerValue();
	}
	
	public Player getOppositePlayer(Player p)
	{
		if (p == null)
			return null;
		if (p.getPlayerValue() == Player.WHITE_PLAYER)
			return new Player(Player.BLUE_PLAYER);
		return new Player(Player.WHITE_PLAYER);
	}
	
	public char getPawnType()
	{
		if (this.playerValue == Player.WHITE_PLAYER)
			return Board.WHITE_PAWN;
		else
			return Board.BLUE_PAWN;
	}
}
